/*Copyright (C) 2009 - 2011 Careil Baptiste

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "../headers.h"

int saved_x = 0;
int saved_y = 0;

void pmove(DIRECTION way, int value) {
	int x, y;
	getyx(stdscr, y, x);

	switch(way) {
	case DROITE :
		x += value;
		break;
	case GAUCHE :
		x -= value;
		break;
	case BAS :
		y += value;
		break;
	case HAUT :
		y -= value;
		break;
	default :
		break;
	}
	if(x == 0) {
		return;
	}
	move(y, x);
}

void goto_begin_line() {
	int x, y;
	getyx(stdscr, y, x);
	move(y, 0);
}

int goto_next_line() {
	int x, y;
	getyx(stdscr, y, x);
	y++;
	return move(y, 0);
}

int goto_previous_line() {
	int x, y;
	getyx(stdscr, y, x);
	y--;
	return move(y, 0);
}

void save_cursor_pos() {
	getyx(stdscr, saved_y, saved_x);
}

void restore_cursor_pos() {
	move(saved_y, saved_x);
}
